package com.bite.book.model;

import com.bite.book.Enum.ResultStatus;
import lombok.Data;

@Data
public class Result<T> {
    private ResultStatus status;
    private String errorMessage;
    private T data;

    public static<T> Result<T> success(T data){
        Result result = new Result<>();
        result.setStatus(ResultStatus.SUCCESS);
        result.setErrorMessage("");
        result.setData(data);
        return result;
    }
    public static<T> Result<T> noLogin(){
        Result result = new Result<>();
        result.setStatus(ResultStatus.NOLOGIN);
        result.setErrorMessage("用户未登录");
        return result;
    }
    public static<T> Result<T> fail(String errorMessage){
        Result result = new Result<>();
        result.setStatus(ResultStatus.FAIL);
        result.setErrorMessage(errorMessage);
        return result;
    }

}
